Don't Use Static? [closed]
Posted
by
Joshiatto
on Programmers
See other posts from Programmers
or by Joshiatto
Published on 2012-08-16T22:15:12Z
Indexed on
2012/12/20
11:12 UTC
Read the original article
Hit count: 482
Possible Duplicate:
Is static universally “evil” for unit testing and if so why does resharper recommend it?
Heavy use of static methods in a Java EE web application?
I submitted an application I wrote to some other architects for code review. One of them almost immediately wrote me back and said "Don't use "static". You can't write automated tests with static classes and methods. "Static" is to be avoided."
I checked and fully 1/4 of my classes are marked "static". I use static when I am not going to create an instance of a class because the class is a single global class used throughout the code.
He went on to mention something involving mocking, IOC/DI techniques that can't be used with static code. He says it is unfortunate when 3rd party libraries are static because of their un-testability.
Is this other architect correct?
© Programmers or respective owner